//
//  UIButton.swift
//  weibo
//
//  Created by hm on 2020/4/20.
//  Copyright © 2020 hm. All rights reserved.
//

import UIKit

extension UIButton {
    //扩展构造函数
    //convenience:便利构造函数
    //1)便利构造函数要明确调用self.init()
    //2)便利构造函数通常在extension中使用
    convenience init(imageName: String,
                            bgImageName: String){
        self.init()
        setImage(UIImage(named: imageName), for: .normal)
        setImage(UIImage(named: imageName + "_highlighted"), for: .highlighted)
        setBackgroundImage(UIImage(named: bgImageName), for: .normal)
        setBackgroundImage(UIImage(named: bgImageName + "_highlighted"), for: .highlighted)
        sizeToFit()
    }
}
